﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Gallio.Framework;
using MbUnit.Framework;
using MbUnit.Framework.ContractVerifiers;
using MobileBroadbandUserBlog.MBLM;
using MobileBroadbandUserBlog.MBLM.Core.Interfaces;
using Rhino.Mocks;

namespace MobileBroadbandLoggingMonitor.FastTests
{
    [TestFixture]
    public class MobileSoftwareFactoryTests
    {
        private readonly MockRepository _mockRepository = new MockRepository();
        private IMobileSoftwareFactory _mobileSoftwareFactory;
        private IMobileSoftware _mobileSoftware;

        [SetUp]
        public void SetUp()
        {
            _mobileSoftwareFactory = _mockRepository.StrictMock<IMobileSoftwareFactory>();
            _mobileSoftware = _mockRepository.StrictMock<IMobileSoftware>();
        }
        [Test]
        public void TestGetMobileSoftwareCollection()
        {
            MobileSoftwareFactory mobileSoftwareFactory = new MobileSoftwareFactory();
            IList<IMobileSoftware> theSoftwares = mobileSoftwareFactory.GetMobileBroadbandSoftware();
            Assert.AreEqual(4, theSoftwares.Count);
        }

        [Test]
        public void TestAddSoftware()
        {
            MobileSoftwareFactory mobileSoftwareFactory = new MobileSoftwareFactory();
            mobileSoftwareFactory.AddMobileBroadbandSoftware(_mobileSoftware);
            Assert.AreEqual(5, mobileSoftwareFactory.GetMobileBroadbandSoftware().Count);
        }

        [Test]
        public void TestAddAndRemoveSoftware()
        {
            MobileSoftwareFactory mobileSoftwareFactory = new MobileSoftwareFactory();
            mobileSoftwareFactory.AddMobileBroadbandSoftware(_mobileSoftware);
            Assert.AreEqual(5, mobileSoftwareFactory.GetMobileBroadbandSoftware().Count);
            mobileSoftwareFactory.RemoveMobileBroadbandSoftware(_mobileSoftware);
            Assert.AreEqual(4, mobileSoftwareFactory.GetMobileBroadbandSoftware().Count);
        }


        [Test]
        [ExpectedException(typeof(ArgumentNullException))]
        public void NullTestAddSoftware()
        {
            MobileSoftwareFactory mobileSoftwareFactory = new MobileSoftwareFactory();
            mobileSoftwareFactory.AddMobileBroadbandSoftware(null);
        }

        [Test]
        [ExpectedException(typeof(ArgumentNullException))]
        public void NullTestRemoveSoftware()
        {
            MobileSoftwareFactory mobileSoftwareFactory = new MobileSoftwareFactory();
            mobileSoftwareFactory.RemoveMobileBroadbandSoftware(null);
        }

    }
}
